<!-- HTML5 sekce pro články -->
      <section id="content">
        <?php if (Auth::instance()->logged_in('admin')): ?>
        <span class="button-white"><a href="<?php echo url::base(); ?>articles/add" title="">Přidat článek</a></span>
        <span class="button-white"><a href="<?php echo url::base(); ?>articles/my" title="">Moje články</a></span>
        <?php endif ?>
        <?php foreach ($articles as $item): ?>
        <div class="block aside">
          <div class="block-left">
            <article class="article">
              <header>
                <h2 class=""><?php echo $item->title ?></h2>
              </header>
              <section>
                <?php if (! empty($item->preview_image)): ?>
                  <img title="<?php echo $item->title ?>" src="<?php echo url::base() ?>files/articles/<?php echo $item->date ?>.jpg" alt="<?php echo $item->title ?> - Fotografie ke článku" />
                <?php endif ?>
                <p><?php echo preg_replace('/\s+?(\S+)?$/', '', substr(strip_tags($item->text), 0, 400)) ?>&hellip</p>
              </section>
              <div class="article-bottom article-bottom-simple"><span class="float-left"><img src="<?php echo url::base() ?>media/img/icons/mini_hearth.png" alt="Oblíbený"><strong>13</strong><img src="<?php echo url::base() ?>media/img/icons/mini_bubble.png" alt="Komentářů"><strong><?php echo $item->article_comments->count_all() ?></strong></span><a href="<?php echo url::base() ?>article/<?php echo $item->id.'-'.$item->seo_title ?>" class="more float-right" title="">číst článek</a></div>
            </article>                                      
            <div class="clear-both"></div>            
          </div>
          <aside class="block-right">
            <h3>Podobné v kategorii</h3>
            <div class="padding-aside">
            <?php
            $in_category_final = array();
            $category_names = array();
            foreach ($item->articles_category->find_all() as $cat_item) {
              $in_category = ORM::factory('articles_category', $cat_item)->article->where('published','=','1')->find_all()->as_array();
              $in_category_final = Arr::merge($in_category_final, $in_category);
              $category_names[] = $cat_item->name;
            }
            shuffle($in_category_final);
            $count_iterations = (int) 1;

            foreach (array_unique($in_category_final) as $category_item) {

              if ($category_item->id != $item->id) {
                echo '<div class="item-line"><h4>' . $category_item->title . '</h4><span><img class="icon" src="'.url::base().'media/img/icons/mini_date.png" alt="" /> ' . Helpers_Photovoice::datum($category_item->date, 'full') . '</span></div>';
              }
              
              if ($count_iterations == (int) 4) {
                break;
              } else {
                $count_iterations++;
              }
            }
            ?>
            </div>
          </aside>  
          <div class="block-bottom aside-bottom"></div>                     
        </div>
        <?php endforeach ?>
      </section>